#include "MySqlManageInstanceGroupStatement.h"

#include "../../../../ast/SQLExpr.h"
#include "../../../../ast/SQLName.h"
#include "../../../../ast/expr/SQLIntegerExpr.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../../utils/listTran.h"

MySqlManageInstanceGroupStatement::MySqlManageInstanceGroupStatement()
{
  groupNames = std::make_shared<std::list<SQLExpr_ptr>>();
}

void MySqlManageInstanceGroupStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlManageInstanceGroupStatement)))
  {
    SQLObject_list_ptr tmp = ListTran::tran_class<SQLExpr, SQLObject>(groupNames);
    acceptChild(visitor, tmp);
    acceptChild(visitor, replication);
    acceptChild(visitor, operation);
  }
  visitor->endVisit(SharedObject(MySqlManageInstanceGroupStatement));
}

string_list_ptr MySqlManageInstanceGroupStatement::getGroupNamesToString()
{
  string_list_ptr names = std::make_shared<std::list<string_ptr>>();
  for (SQLExpr_ptr groupName : *groupNames)
  {
    names->push_back(groupName->toString());
  }
  return names;
}

SQLExpr_list_ptr  MySqlManageInstanceGroupStatement::getGroupNames()
{
  return groupNames;
}

SQLIntegerExpr_ptr MySqlManageInstanceGroupStatement::getReplication()
{
  return replication;
}

void MySqlManageInstanceGroupStatement::setReplication(SQLIntegerExpr_ptr replication)
{
  this->replication = replication;
}

SQLName_ptr MySqlManageInstanceGroupStatement::getOperation()
{
  return operation;
}

void MySqlManageInstanceGroupStatement::setOperation(SQLName_ptr operation)
{
  this->operation = operation;
}
